#
import os
import urllib2
from urlparse import urlparse

def download(url, dst_file_path):
    try:
        f = urllib2.urlopen(url)
        with open(dst_file_path, "wb") as dst_file:
            dst_file.write(f.read())
        print "Success"
    except:
        print "Fail"
        raise

index = 0
dst_folder = "D:\\temp\\pix"
if not os.path.exists(dst_folder):
    os.makedirs(dst_folder)
#url = "http://www.pulsarmedia.eu/data/media/822/Asian_Girl_Sexy_Wallpaper_19.jpg"
#for index in list(reversed(range(10))):
#    print url.format(index)

for index in range(80,100,1):
    url = "http://www.pulsarmedia.eu/data/media/822/Asian_Girl_Sexy_Wallpaper_{0}.jpg".format(index)
    o = urlparse(url)
    filename = os.path.basename(o.path)
    print "Downloading {0}".format(filename)

    dst_file_path = os.path.join(dst_folder, filename)
    download(url, dst_file_path)
